package oo.day05;

//找一组图形中的最大面积
public class shapeTest {

	public static void main(String[] args) {
		shape[] shapes = new shape[7];
		shapes[0] = new square(1);
		shapes[1] = new square(2);
		shapes[2] = new circular(1);
		shapes[3] = new circular(2);
		shapes[4] = new six(1);
		shapes[5] = new six(2);
		shapes[6] = new six(3);
		calculate(shapes);
		
		
	}
	
	public static void calculate(shape[] shapes) {
		double maxArea = shapes[0].area();
		int index = 0;
		for(int i = 1; i < shapes.length; i++) {
			double area = shapes[i].area();
			if(area > maxArea) {
				maxArea = area;
				index = i;
			}
		}
		System.out.println("最大面积="+maxArea+",下标是:"+index);
	}
}

abstract class shape {
	protected int a;

	abstract double area();
}

class square extends shape {
	square(int a) {
		this.a = a;
	}

	public double area() {
		return 0.0625 * a * a;
	}
}

class circular extends shape {
	circular(int a) {
		this.a = a;
	}

	public double area() {
		return 0.0796 * a * a;
	}
}

class six extends shape{
	six(int a){
		this.a = a;
	}
	public double area() {
		return 0.0721 * a * a;
	}
}